using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Ornament.MemberShip;
using Ornament.Messages;
using Ornament.Web.ModelBinder;

namespace Ornament.MVCWebFrame
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
         
            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
                );
            routes.MapRoute("workList",
                            "Messages/Works/{pageSize}/{pageIndex}/{state}/{template}",
                            new
                            {
                                Controller = "Messages",
                                action = "Works",
                                pageSize = 40,
                                pageIndex = 0,
                                template = "default",
                                state = ReadStatus.UnRead
                            }
                );

        }

        protected void Application_Start()
        {
            log4net.Config.XmlConfigurator.Configure();
            AreaRegistration.RegisterAllAreas();
            ModelBinders.Binders.Add(typeof(User), new UserBinder());
            ModelBinders.Binders.Add(typeof(UserGroup), new UserGroupBinder());
            RegisterRoutes(RouteTable.Routes);
        }
    }
}